﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net;
using System.IO;
using System.Web.Script.Serialization;
using System.Text;
using CinePlancito.Dominio;

namespace CinePlancito.Controllers
{
    public class CarteleraController : Controller
    {
        string RestCarteleras = "http://localhost:15497/Carteleras.svc/Carteleras";
        JavaScriptSerializer js = new JavaScriptSerializer();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ListaCarteleras()
        {
            HttpWebRequest req = (HttpWebRequest)WebRequest
                .Create(RestCarteleras + "/");
            req.Method = "GET";
            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            StreamReader reader = new StreamReader(res.GetResponseStream());
            string carteleraJson = reader.ReadToEnd();
            List<Cartelera> carteleras = js.Deserialize<List<Cartelera>>(carteleraJson);
            return View(carteleras);
        }

    }
}
